using MediatR;
using System.ComponentModel.DataAnnotations;

namespace B.S.NewMedical.Api.Write.Application.Command.ContentManagement.Patient
{
    /// <summary>
    /// 新增患者命令
    /// </summary>
    public class AddPatientCommand : IRequest<int>
    {
        /// <summary>
        /// 用户Id（可选，关联用户账号）
        /// </summary>
        public int? AccountId { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [Required(ErrorMessage = "患者姓名不能为空")]
        [StringLength(50, ErrorMessage = "患者姓名长度不能超过50个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 性别（true=男，false=女）
        /// </summary>
        [Required(ErrorMessage = "性别不能为空")]
        public bool Sex { get; set; }

        /// <summary>
        /// 出生日期
        /// </summary>
        [Required(ErrorMessage = "出生日期不能为空")]
        public DateTime DateOfBirth { get; set; }

        /// <summary>
        /// 联系方式
        /// </summary>
        [Required(ErrorMessage = "联系方式不能为空")]
        [StringLength(20, ErrorMessage = "联系方式长度不能超过20个字符")]
        [RegularExpression(@"^1[3-9]\d{9}$", ErrorMessage = "请输入正确的手机号码格式")]
        public string ContactInfo { get; set; } = string.Empty;

        /// <summary>
        /// 身份证号
        /// </summary>
        [Required(ErrorMessage = "身份证号不能为空")]
        [StringLength(18, MinimumLength = 15, ErrorMessage = "身份证号长度应为15-18位")]
        [RegularExpression(@"^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$|^[1-9]\d{5}\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}$", ErrorMessage = "请输入正确的身份证号码格式")]
        public string IDCard { get; set; } = string.Empty;

        /// <summary>
        /// 现居地址
        /// </summary>
        [StringLength(200, ErrorMessage = "现居地址长度不能超过200个字符")]
        public string? CurrentAddress { get; set; }

        /// <summary>
        /// 传染病史
        /// </summary>
        [StringLength(500, ErrorMessage = "传染病史长度不能超过500个字符")]
        public string? InfectiousDiseaseHistory { get; set; }

        /// <summary>
        /// 遗传病信息
        /// </summary>
        [StringLength(500, ErrorMessage = "遗传病信息长度不能超过500个字符")]
        public string? GeneticDiseaseInfo { get; set; }

        /// <summary>
        /// 操作人
        /// </summary>
        public string? CreatePeople { get; set; }
    }
}